package mcom.xmks.bluetooth.mesh;

import android.app.Application;

import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.mmkv.MMKV;

import java.util.regex.Pattern;

import cn.wch.meshlib.core.MeshServer;
import mcom.xmks.bluetooth.mesh.ota.UpdateFileResolver;
import mcom.xmks.bluetooth.mesh.utils.ConvertUtil;

public class MeshApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        MMKV.initialize(this);
        try {
            MeshServer.getInstance().init(this);
            //创建存放升级文件的目录
            UpdateFileResolver.createPrivateFolder(this);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //Tencent-Bugly,为了适配部分机型,需要搜集崩溃信息进行优化。
        CrashReport.initCrashReport(getApplicationContext(), "5d06fffded", false);
        boolean key = getKey("gvcvgbv1234_,.?/~`@#$%^&*()\\-\\+\\=<>{}|[]\\:;'\"");
    }

    private boolean getKey(String userKey){
        Pattern p=Pattern.compile("^[a-zA-Z0-9_,.?/~`@#$%^&*()\\-\\+\\=<>{}|\\[\\]\\\\:;'\"\"]*$");
        boolean m= userKey.matches(p.pattern());
        return m;
    }
}
